# Huawei Technologies Co.,Ltd.

set(STRICT_EQUAL_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/strictequal.txt)
set(STRICT_EQUAL_BIN ${CMAKE_CURRENT_BINARY_DIR}/strictequal.abc)
set(STRICT_EQUAL_PA ${CMAKE_CURRENT_BINARY_DIR}/strictequal.pa)
set(STRICT_EQUAL_JS ${CMAKE_CURRENT_SOURCE_DIR}/strictequal.js)
set(STRICT_EQUAL_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${STRICT_EQUAL_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${STRICT_EQUAL_OUTPUT}
    COMMENT "running javascript strictequal testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${STRICT_EQUAL_JS} --dump-assembly --output ${STRICT_EQUAL_BIN} > ${STRICT_EQUAL_PA}
    COMMAND rm -f ${STRICT_EQUAL_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${STRICT_EQUAL_OUTPUT}
    COMMAND bash ${STRICT_EQUAL_VERIFY} ${STRICT_EQUAL_OUTPUT}
)
add_custom_target(strictequal
    DEPENDS ${STRICT_EQUAL_OUTPUT} ${STRICT_EQUAL_VERIFY}
)
add_dependencies(strictequal es2panda ark)
add_dependencies(ecmascript_common_tests strictequal)
